import Vue from 'vue'
import VueRouter from 'vue-router'
import shouye from  '../views/ShouYe.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: shouye,
    meta: {
      title: '首页 - 心食谱'
    }
  },
  {
    path: '/shouye',
    name: 'routeName',
    component: () => import('../views/ShouYe.vue'),
    meta: {
      title: '首页 - 心食谱'
    }
  },
  {
    path: '/recipemh/:mh',
    name: 'routeName',
    props:true,
    component: () => import('../views/RecipeMh.vue'),
    meta: {
      title: '心食谱'
    }
  },
  {
    path: '/userzy',
    name: 'routeName',
    component: () => import('../views/UserZy.vue'),
    meta: {
      title: '个人主页'
    }
  },
  {
    path: '/userkj/:name',
    name: 'routeName',
    props:true,
    component: () => import('../views/UserKj.vue'),
    meta: {
      title: '个人空间'
    }
  },
  {
    path: '/recipexq/:rd',
    name: 'routeName',
    props:true,
    component: () => import('../views/RecipeXq.vue'),
    meta: {
      title: '心食谱'
    }
  },
  {
    path: '/logind',
    name: 'routeName',
    component: () => import('../views/Logind.vue'),
    meta: {
      title: '登录'
    }
  },
  {
    path: '/gonggao',
    name: 'routeName',
    component: () => import('../views/GongGao.vue'),
    meta: {
      title: '公告'
    }
  },
  {
    path: '/gonggao1',
    name: 'routeName',
    component: () => import('../views/GongGao1.vue'),
    meta: {
      title: '公告'
    }
  },
  {
    path: '/gonggao2',
    name: 'routeName',
    component: () => import('../views/GongGao2.vue'),
    meta: {
      title: '公告'
    }
  },
  {
    path: '*',
    name: 'routeName',
    component: () => import('../views/NotFound.vue'),
    meta: {
      title: '心食谱'
    }
  },
  {
    path: '/userphb',
    name: 'routeName',
    component: () => import('../views/UserPhb.vue'),
    meta: {
      title: '美食家'
    }
  },
  {
    path: '/recipexx',
    name: 'routeName',
    component: () => import('../views/RecipeXx.vue'),
    meta: {
      title: '心食谱'
    }
  },
  {
    path: '/recipeflxq/:kw',
    name: 'routeName',
    props:true,
    component: () => import('../views/RecipeFlXq.vue'),
    meta: {
      title: '心食谱'
    }
  },
  {
    path: '/fabiao',
    name: 'routeName',
    component: () => import('../views/FaBiao.vue'),
    meta: {
      title: '新食谱'
    }
  },
  {
    path: '/recipelb',
    name: 'routeName',
    component: () => import('../views/RecipeLb.vue'),
    meta: {
      title: '心食谱'
    }
  },
  {
    path: '/houtaizy',
    name: 'routeName',
    component: () => import('../views/HouTaizy.vue'),
    meta: {
      title: '后台管理',
      hidetf:true
    },
    redirect:'/houtaizy/yh', 
    children:[{
      path: 'yh',
      name: 'yh',
      component: () => import('../views/HouTaiyh.vue'),
      meta: {
        title: '后台管理',
        hidetf:true
      },
    },{
      path: 'sp',
      name: 'sp',
      component: () => import('../views/HouTaisp.vue'),
      meta: {
        title: '后台管理',
        hidetf:true
      },
    },{
      path: 'fl',
      name: 'fl',
      component: () => import('../views/HouTaifl.vue'),
      meta: {
        title: '后台管理',
        hidetf:true
      },
    },]
  },
  // {
  //   path: '/houtaifl',
  //   name: 'routeName',
  //   component: () => import('../views/HouTaifl.vue'),
  //   meta: {
  //     title: '后台管理',
  //     hidetf:true
  //   }
  // },
  // {
  //   path: '/houtaisp',
  //   name: 'routeName',
  //   component: () => import('../views/HouTaisp.vue'),
  //   meta: {
  //     title: '后台管理',
  //     hidetf:true
  //   }
  // },
  // {
  //   path: '/houtaiyh',
  //   name: 'routeName',
  //   component: () => import('../views/HouTaiyh.vue'),
  //   meta: {
  //     title: '后台管理',
  //     hidetf:true
  //   }
  // },
  
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// 全局前置守卫:
// 凡是路由的跳转操作, 都会触发守卫
router.beforeEach((to, from, next) => {
  document.title = to.meta.title

  next() //放行: 让路由继续后续工作
})
export default router
